/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1644910415431_4500';

  // add your middleware config here
  config.middleware = [];

  // config/config.default.js
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    database: 'egg',
    username: 'root',
    password: 'jh0427..',
    // 配置数据库时间为东八区北京时间
    timezone: '+08:00',
    define: {
      freezeTableName: true, // 强制表名称等于模型名称
      timestamps: false, // 禁用时间戳
    },
  };

  config.jwt = {
    secret: 'ylw', // 自定义 token 的加密条件字符串
  };

  config.security = {
    csrf: {
      enable: false,
      ignoreJSON: true,
    },
    domainWhiteList: ['*'],
  };

  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  };

  config.oss = {
    client: {
      bucket: 'uat-yxdc-shop-material',
      region: 'oss-cn-shenzhen',
      endpoint: 'https://oss-cn-shenzhen.aliyuncs.com',
      accessKeyId: 'LTAI4GHmUxXW9kH1y3vSa18w', //创建bucket生成的accessKeyId
      accessKeySecret: 'a58ttESGjEE80FpjSaDDZiDA7JUbWD', //创建bucket生成的accessKeySecret
      secure: true,
    },
  };

  // 跨域相关配置
  config.cors = {
    origin: 'http://localhost:8000', // 允许哪个地址跨域请求
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', // 允许哪些方法跨域请求
    credentials: true, // 允许前端携带cookie
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
